/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package FormImg;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.image.*;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.*;

/**
 *
 * @author rodrigo
 */
public class Exampl {
 
private static BufferedImage image = null;
private JPanel panel;
        
public Exampl()
{
final JFrame imageFrame = new JFrame ();
    imageFrame.setLayout ( new BorderLayout () );

    panel = new JPanel ()
    {
        protected void paintComponent ( Graphics g )
        {
            super.paintComponent ( g );

            if ( image != null )
            {
                g.drawImage ( image, getWidth () / 2 - image.getWidth () / 2,
                        getHeight () / 2 - image.getHeight () / 2, this );
            }
        }
    };
    
    imageFrame.add ( panel, BorderLayout.CENTER );

    
    imageFrame.setSize ( 500, 500 );
    imageFrame.setLocationRelativeTo ( null );
    imageFrame.setVisible ( true );
        
}



public void setImage(BufferedImage img)
{
    image=img;
    panel.repaint();
}

public static void main(String args[]) throws IOException
{
    BufferedImage cat = ImageIO.read(new File("C:/Users/rodrigo/Desktop/LIC EN SISTEMAS/universidad_2012/UNLU_7cuat/PROCESAMIENTO DE IMAGEN Y SONIDO/TPP2/Trabajo Práctico Clase 19 mayo/imagenes/bird.png"));
    Exampl minuevoejemplo = new Exampl();
    minuevoejemplo.setImage(cat);

}


}
